package com.wyg.blog.service.serviceimpl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wyg.blog.mapper.TypeMapper;
import com.wyg.blog.model.blog.Type;
import com.wyg.blog.service.blog.TypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @description:
 * @author: WYG
 * @time: 2020/6/30 20:27
 */
@Service
public class TypeServiceImpl implements TypeService {
    @Autowired
    TypeMapper typeMapper;

    @Override
    public List<Type> selectAllTypes() {
        return typeMapper.getAllTypes();
    }

    @Override
    public List<Type> selectLatestTypes() {
        return typeMapper.getLatestTypes();
    }

    @Override
    public Integer selectTypeCount() {
        return typeMapper.getTypeCount();
    }

    @Override
    public IPage<Type> selectSomeTypes(Page<?> page) {
        return typeMapper.getSomeTypes(page);
    }

    @Override
    public String selectTypeName(Integer id) {
        return typeMapper.getTypeName(id);
    }

    @Override
    public Type selectTypeByName(String name) {
        return typeMapper.getTypeByName(name);
    }

    @Override
    public Type selectTypeById(Integer id) {
        return typeMapper.getTypeById(id);
    }

    @Override
    public boolean insertType(Type type) {
        return typeMapper.addType(type);
    }

    @Override
    public boolean renewTypeState(Integer id, boolean state) {
        return typeMapper.updateTypeState(id, state);
    }

    @Override
    public boolean renewType(Integer id, String type) {
        return typeMapper.updateType(id, type);
    }


    @Override
    public boolean removeType(Integer id) {
        return typeMapper.deleteType(id);
    }

    @Override
    public List<Type> fuzzySearch(String type) {
        return typeMapper.getTypeByLike(type);
    }
}
